#include "woptions/woptions.h"
#include "test.h"

#include <fstream>
#include <cstdio>

BOOST_AUTO_TEST_CASE( test_read_from_file )
{
	{
		std::ofstream temp("temp.txt");
		temp << "1 2\n3\t4\r5 \"6\n6\" \\\"7";
		BOOST_REQUIRE_EQUAL( temp.good(), true );
	}
	
	std::vector<std::string> args(3);
	args[0] = "[";
	args[1] = "@temp.txt";
	args[2] = "]";
	
	woptions::read_from_file t;
	t(args);
	
	std::remove("temp.txt");
	
	BOOST_REQUIRE_EQUAL( args.size(), size_t(9) );
	BOOST_CHECK_EQUAL( args[0], "[" );
	BOOST_CHECK_EQUAL( args[1], "1" );
	BOOST_CHECK_EQUAL( args[2], "2" );
	BOOST_CHECK_EQUAL( args[3], "3" );
	BOOST_CHECK_EQUAL( args[4], "4" );
	BOOST_CHECK_EQUAL( args[5], "5" );
	BOOST_CHECK_EQUAL( args[6], "6\n6" );
	BOOST_CHECK_EQUAL( args[7], "\"7" );
	BOOST_CHECK_EQUAL( args[8], "]" );
}
